package domain;

import java.util.Calendar;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "profiles")
public class Profile extends PersistentEntity {

	@OneToOne(mappedBy="profile", fetch = FetchType.EAGER)
	private User user;

	@Column(nullable = false)
	private String studentcode;

	@Column(nullable = false)
	private Date birthdate;

	private String phones;

	private String emails;

	private String experience;

	private String education;

	private String web;

	private String recommendations;

	private Image photo;

	private String title;

	private String actualjob;

	private String links;

	private String extract;

	private String interests;

	private String knowldege;

	@Enumerated
	private Gender gender;
	
	@Enumerated
	private MaritalStatus maritalStatus;

	private String address;

	public Profile(User user, String studentcode, Date birthdate, String phones, String personalEmails){
		super();
		this.user = user;
		this.studentcode = studentcode;
		this.birthdate = birthdate;
		this.phones = phones;
		this.emails = personalEmails;
	}
	
	public Profile(User user, String studentcode, Date birthdate,
			String phones, String personalEmails, String experience, String education,
			String web, String recommendations, Image photo, String title,
			String actualjob, String links, String extract, String interests,
			String knowldege, MaritalStatus maritalstatus, String address) {
		super();
		this.user = user;
		this.studentcode = studentcode;
		this.birthdate = birthdate;
		this.phones = phones;
		this.emails = personalEmails;
		this.experience = experience;
		this.education = education;
		this.web = web;
		this.recommendations = recommendations;
		this.photo = photo;
		this.title = title;
		this.actualjob = actualjob;
		this.links = links;
		this.extract = extract;
		this.interests = interests;
		this.knowldege = knowldege;
		this.maritalStatus = maritalstatus;
		this.address = address;
	}

	// hibernate
	protected Profile() {
	}

	public User getUser() {
		return user;
	}

	public String getStudentcode() {
		return studentcode;
	}

	public Date getBirthdate() {
		return birthdate;
	}
	
	public String getBirthdateString() {
		Calendar cal = Calendar.getInstance();
		cal.setTime(birthdate);
		int monthInt = cal.get(Calendar.MONTH)+1;
		return cal.get(Calendar.DATE) + "/" + monthInt + "/" + cal.get(Calendar.YEAR);
	}
	
	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	public String getPhones() {
		return phones;
	}
	
	public void setPhones(String phones) {
		this.phones = phones;
	}

	public String getEmails() {
		return emails;
	}
	
	public void setEmails(String emails) {
		this.emails = emails;
	}

	public String getExperience() {
		return experience;
	}

	public String getEducation() {
		return education;
	}

	public void setEducation(String education) {
		this.education = education;
	}

	public String getWeb() {
		return web;
	}

	public String getRecommendations() {
		return recommendations;
	}

	public Image getPhoto(){
		return photo;
	}
	
	public void setPhoto(Image photo){
		this.photo = photo;
	}
	
	public String getTitle() {
		return title;
	}

	public String getActualjob() {
		return actualjob;
	}

	public String getLinks() {
		return links;
	}

	public String getExtract() {
		return extract;
	}

	public String getInterests() {
		return interests;
	}

	public String getKnowldege() {
		return knowldege;
	}

	public Gender getGender() {
		return gender;
	}
	
	public void setGender(Gender gender) {
		this.gender = gender;
	}
	
	public MaritalStatus getMaritalstatus() {
		return maritalStatus;
	}
	
	public void setMaritalstatus(MaritalStatus maritalstatus) {
		this.maritalStatus = maritalstatus;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Override
	public String toString() {
		return "Profile [user=" + user.toString() + ", studentcode=" + studentcode
				+ ", birthdate=" + birthdate + ", phones=" + phones
				+ ", emails=" + emails + ", experience=" + experience
				+ ", education=" + education + ", web=" + web
				+ ", recommendations=" + recommendations + ", photo=" + photo
				+ ", title=" + title + ", actualjob=" + actualjob + ", links="
				+ links + ", extract=" + extract + ", interests=" + interests
				+ ", knowldege=" + knowldege + ", maritalstatus="
				+ maritalStatus + ", address=" + address + "]";
	}

}